
package com.rx.mgt.service;  

import java.util.List;

import com.rx.mgt.dao.DomainSignDao;
import com.rx.mgt.dao.SysOpreateDao;
import com.rx.mgt.domain.DomainSign;
import com.rx.mgt.domain.EmailListDomain;
import com.rx.mgt.domain.SysOpreate;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rx.mgt.dao.DomainDao;
import com.rx.mgt.domain.Domain;
import com.rx.mgt.po.UsersBo;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/** 
 * ClassName:DomainService 
 * Function :
 * Reason   : 
 * Date     :Feb 1, 2017 10:30:41 AM 
 * @author   luolei 
 * @since    JDK 1.6
 */
@Service
public class DomainService {
    @Autowired
    DomainDao domainDao;
    @Autowired
    DomainSignDao domainSignDao;
    @Autowired
    SysOpreateDao sysOpreateDao;
    public List list(){
        return domainDao.list();
    }
    public List<Domain>  getDomainInfoExt(UsersBo usersBo){
        return domainDao.getDomainInfoExt(usersBo);
    }


    @Transactional
    public DomainSign getDomainSignContentByDomain(String domain) {
        return domainDao.getDomainSignContentByDomain(domain);
    }

    @Transactional(readOnly = false,propagation = Propagation.REQUIRED)
    public void saveOrUpdateDomainSing(DomainSign sign) {
        domainSignDao.saveOrUpdate(sign);
    }

    @Transactional
    public SysOpreate getSysOpreateByDomain(String domain) {

        return domainDao.getSysOpreateByDomain(domain);
    }

    @Transactional(readOnly = false,propagation = Propagation.REQUIRED)
    public int updateSysOpreate(SysOpreate sysOpreate) {
        String domain = sysOpreate.getDomain();
        if(StringUtils.isBlank(domain)){
            return 0;
        }
        sysOpreateDao.update(sysOpreate);
        if(sysOpreate.getId()!=null){
            return 1;
        }else{
            return 0;
        }
    }

    @Transactional
    public List getDomainInfoExtQy(UsersBo usersBo) {
        return domainDao.getDomainInfoExtQy(usersBo);
    }
}
  